import { User, UserProfile } from "@/types/data";
import { ProfileAction } from "@/types/store";
type ProfileState = {
    user: User;
    userProfile: UserProfile;
};
const initialState = {
    user: {},
    userProfile: {},
} as ProfileState;
const profile = (state = initialState, action: ProfileAction): ProfileState => {
    switch (action.type) {
        case "profile/getUser":
            return {
                ...state,
                user: action.payload,
            };
        case "profile/getUserProfile":
            return {
                ...state,
                userProfile: action.payload,
            };
        case "profile/update":
            // 合并
            return {
                ...state,
                userProfile: {
                    ...state.userProfile,
                    ...action.payload,
                },
            };
        default:
            return state;
    }
};
export default profile;
